﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WpfDemo.Converter
{
    public class IconConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return "";
            var temp = value.ToString().Replace("&#x", "").Replace(";", "");
            if (!string.IsNullOrEmpty(temp))           
                return ((char)int.Parse(temp, NumberStyles.HexNumber)).ToString();            
            else
                return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;           
        }
    }
}
